module.exports = {
    /**
     * 修改数据
     * @url admin/kong/sys/update 前端调用的url参数地址
     * data 请求参数 说明
     * res 返回参数说明
     * @param {Number} code 错误码，0表示成功
     * @param {String} msg 详细信息
     */
    main: async (event) => {
        let { data = {}, userInfo, util, filterResponse, originalParam } = event;
        let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
        let { uid } = data;
        let res = { code: 0, msg: 'ok' };
        // 业务逻辑开始-----------------------------------------------------------
        let {
            _id,
            enterprise_name,
            enterprise_info,
            enterprise_image,
            job_description,
            job_image,
            antivirus_records,
            statement_qualification,
            driving_license,
            person1,
            person2,
        } = data;

        // if (vk.pubfn.isNullOne(_id)) {
        //     return { code: -1, msg: '参数错误' };
        // }

        let dbName = "tm-deliveryinfo";
        let info = await vk.baseDao.findByWhereJson({
            dbName: dbName,
            whereJson: {
                user_id: uid,
            }
        });
        if (vk.pubfn.isNull(info)) {
            res.id = await vk.baseDao.add({
                dbName,
                dataJson: {
                    user_id: uid,
                    enterprise_name,
                    enterprise_info,
                    enterprise_image,
                    job_description,
                    job_image,
                    antivirus_records,
                    statement_qualification,
                    driving_license,
                    person1,
                    person2,
                }
            });
        } else {
            await vk.baseDao.updateById({
                dbName,
                id: _id,
                dataJson: {
                    enterprise_info,
                    enterprise_name,
                    enterprise_image,
                    job_description,
                    job_image,
                    antivirus_records,
                    statement_qualification,
                    driving_license,
                    person1,
                    person2,
                }
            });
        }

        // 业务逻辑结束-----------------------------------------------------------
        return res;
    }

}
